package com.easepal802s.project.ui.presenter;


/**
 * Created by FHB on 2018/2/1.
 */


import com.ogawa.base.Constant.BleConstant;
import com.easepal802s.project.ble.HexUtils;
import com.easepal802s.project.ui.iview.IAdvancedMassageView;

/**
 * Created by fhb on 2018/2/1.
 */


public class AdvancedMassagePressenter extends MBasePresenter {
    IAdvancedMassageView mView;
    private byte mByteStart;
    private byte mByte5;
    private byte mByte6;
    private byte mByte10;
    private String mScanData ="-1";
    public AdvancedMassagePressenter(IAdvancedMassageView view) {
        mView = view;
    }


    @Override
    public void getDatas(String data) {
        //当前运行的模式
        //当前运行的模式
        if (data.startsWith(BleConstant.BAG1_HEAD)) {
            byte[] buffer = HexUtils.hexToByte(data);
            byte byte3 =buffer[3];
            if(mByteStart!=byte3){
                //暂停标志
                mByteStart = byte3;
                if (HexUtils.getByteInPosition(data,3,1).equals("1")) {
                    mView.isStart(true);

                } else {
                    mView.isStart(false);
                }
                mView.getPowerState();
            }
                if (!mScanData.equals(HexUtils.getByteInPosition(data, 4, 4))) {
                     mScanData = HexUtils.getByteInPosition(data, 4, 4);
                    if (mScanData.equals("1")) {
                        mView.isScanning();
                    }


                }


        }

    }




}

